public class DisappearedNumber {
    public static void main(String[] args) {
        int[] num = {3, 0, 1};
        System.out.println("消失的数字为：" + missingNumber(num));
    }

    public static int missingNumber(int[] num) {
        int i;
        int back = 0;

        for (i = 0; i <= num.length; i++) {
            back ^= i;
            if (i < num.length) {
                back ^= num[i];
            }
        }

        return back;
    }
}
